package com.zj.healthmanage.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zj.healthmanage.entity.PageResult;
import com.zj.healthmanage.entity.QueryPageBean;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.zj.healthmanage.pojo.Checkitem;
import com.zj.healthmanage.mapper.CheckitemMapper;
import com.zj.healthmanage.service.CheckitemService;

import java.util.List;

@Service
public class CheckitemServiceImpl implements CheckitemService{

    @Resource
    private CheckitemMapper checkitemMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return checkitemMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Checkitem record) {
        return checkitemMapper.insert(record);
    }

    @Override
    public int insertSelective(Checkitem record) {
        return checkitemMapper.insertSelective(record);
    }

    @Override
    public Checkitem selectByPrimaryKey(Integer id) {
        return checkitemMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Checkitem record) {
        return checkitemMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Checkitem record) {
        return checkitemMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageResult queryCheckItemByPage(QueryPageBean queryPageBean) {
        Integer currentPage = queryPageBean.getCurrentPage();
        Integer pageSize = queryPageBean.getPageSize();
        String queryString = queryPageBean.getQueryString();
        PageHelper.startPage(currentPage,pageSize);
        Page<Checkitem> page = checkitemMapper.queryCheckItemByPage(queryString);
        long total = page.getTotal();
        List<Checkitem> rows = page.getResult();
        return new PageResult(total,rows);
    }

    @Override
    public List<Checkitem> queryAll() {
        return checkitemMapper.queryAll();
    }

}
